package service.impl;

import dao.AdminDao;
import dao.RoleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import po.Admin;
import service.AdminService;

import java.util.List;

@Service
@Transactional
public class AdminServiceImpl implements AdminService {
    // 注解注入 AdminDao
    @Autowired
    private AdminDao adminDao;

    @Override
    public boolean addAdmin(Admin admin) {
        return this.adminDao.addAdmin(admin) > 0;
    }

    @Override
    public boolean editAdmin(Admin admin) {
        return this.adminDao.editAdmin(admin) > 0;
    }

    @Override
    public boolean updateAdminAvatar(Admin admin) {
        return false;
    }

    @Override
    public boolean existAdmin(String admin) {
        return false;
    }

    @Override
    public boolean veritypasswd(String username, String password) {
        return this.adminDao.verifyPassword(username, password) > 0;
    }

    @Override
    public boolean deleteAdmin(Integer id) {
        return this.adminDao.deleteAdmin(id) > 0;
    }

    @Override
    public List<Admin> allAdmin(Admin admin) {
        return this.adminDao.allAdmin(admin);
    }
    // 根据 id 获取客户信息
    @Override
    public Admin adminOfId(Integer id) {
        return this.adminDao.adminOfId(id);
    }

    @Override
    public Admin loginStatus(String username) {
        return  this.adminDao.loginStatus(username);
    }

    @Override
    public Boolean isEnableAdmin(Integer id, Integer flag) {
        return adminDao.isEnableAdmin(id,flag) > 0;
    }

    @Override
    public Admin getAdminOfId(Integer id) {
        return this.adminDao.getAdminOfId(id);
    }

}
